package com.cc.service.impl;

import com.cc.mapper.ClazzsMapper;
import com.cc.pojo.CLazz;
import com.cc.pojo.EmpQueryParam;
import com.cc.pojo.PageResult;
import com.cc.service.ClazzsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class ClazzsServiceImpl implements ClazzsService {
    @Autowired
    private ClazzsMapper clazzsMapper;

    @Override
    public PageResult<CLazz> page(EmpQueryParam empQueryParam) {
        PageHelper.startPage(empQueryParam.getPage(),empQueryParam.getPageSize());
        List<CLazz> clazzsList=clazzsMapper.list(empQueryParam);
        Page<CLazz> clazzsPage=(Page<CLazz>) clazzsList;
        return new PageResult(clazzsPage.getTotal(),clazzsPage.getResult());


    }

    @Override
    public void delect(Integer id) {
        clazzsMapper.delect(id);
    }

    @Override
    public void add(CLazz clazz) {
        clazz.setCreateTime(LocalDateTime.now());
        clazz.setUpdateTime(LocalDateTime.now());
        clazzsMapper.add(clazz);

    }

    @Override
    public CLazz getID(Integer id) {
    return clazzsMapper.getID(id);

    }

    @Override
    public void update(CLazz clazz) {
        clazz.setUpdateTime(LocalDateTime.now());
        clazzsMapper.update(clazz);
    }

    @Override
    public List<CLazz> findAll() {

        return clazzsMapper.findAll();
    }


}
